package com.colortea.action.frontstage.pay;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.InterceptorRefs;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.colortea.action.backstage.base.BaseTAction;
import com.colortea.action.backstage.base.DataCollectionTAction;
import com.opensymphony.xwork2.ActionContext;

@ParentPackage("colortea")
@Namespace("/paysuccess")
@InterceptorRefs({ @InterceptorRef("defaultStack") })
public class PaySuccessAction extends BaseTAction {

	@Resource
	private DataCollectionTAction dataCollectionTAction;

	/**
	 * 支付宝商户订单号 由商户自己生成
	 */
	private String out_trade_no;

	/**
	 * 商品名称
	 */
	private String subject;

	/**
	 * 支付金额
	 */
	private String total_fee;

	public String getTotal_fee() {
		return total_fee;
	}

	public void setTotal_fee(String total_fee) {
		this.total_fee = total_fee;
	}

	public String getOut_trade_no() {
		return out_trade_no;
	}

	public void setOut_trade_no(String out_trade_no) {
		this.out_trade_no = out_trade_no;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	/**
	 * 页面跳转同步通知页面路径
	 * 
	 * @return
	 */
	@Action(value = "success", results = { @Result(name = "success", type = "freemarker", location = "/WEB-INF/theme/default/shop/paysuccess.ftl") })
	public String success() {
		// 获取商城公众信息
		dataCollectionTAction.putBaseInfoToContext();
		ActionContext.getContext().put("out_trade_no", this.getOut_trade_no());
		ActionContext.getContext().put("subject", this.getSubject());
		ActionContext.getContext().put("total_fee", this.getTotal_fee());
		return SUCCESS;
	}

}
